load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_license//rules:license.bzl", "license")

license(
    name = "license",
    license_kinds = ["@rules_license//licenses/spdx:BSL-1.0"],
    license_text = "LICENSE",
)

# Split this header out to avoid a dependency on doctest in the lexy lib.
TEST_HDRS = [
    "include/lexy_ext/parse_tree_doctest.hpp",
]

cc_library(
    name = "lexy",
    srcs = glob(["src/**/*.cpp"]),
    hdrs = glob(
        ["include/**/*.hpp"],
        exclude = TEST_HDRS,
    ),
    defines = ["LEXY_HAS_UNICODE_DATABASE=1"],
    includes = ["include"],
    visibility = ["//visibility:public"],
)

cc_test(
    name = "lexy_test",
    size = "small",
    srcs = glob([
        "tests/lexy/**/*.cpp",
        "tests/lexy/**/*.hpp",
        "tests/lexy_ext/**/*.cpp",
    ]) + TEST_HDRS + ["tests/doctest_main.cpp"],
    defines = ["LEXY_EXPERIMENTAL=1"],
    deps = [
        ":lexy",
        "@doctest//doctest",
    ],
)
